<?php

/**
 * Created by PhpStorm.
 * User: 王琳
 * Date: 2015/12/17
 * Time: 13:58
 */
class StampModel extends  Model{

    /*获取年份*/
    public function get_year(){
        $year = D("health_report")->field("distinct rpt_time")->select();
        if(!empty($year)){
           return $year;
        }
        return null;
    }

    /*获取需要打印的份数*/
    public function get_portion_number(){
        /*给定条件*/
        $data['level'] = 3;
        $data['is_over'] = 1;
        $result = D("health_report")->field("count(*) as portion_number")->where($data)->select();
        if(!empty($result)){
            return $result;
        }
        return array('portion_number'=>0);
    }

    /*获取需要打印报告的数据*/
    public function get_stamp_data(){
        //条件
        $data['level'] = 3;
        $data['is_over'] = 1;
        $reports = D("health_report")->where($data)->select();
        if(!empty($reports)){
            return $reports;
        }
        return array();
    }

    /*删除报告*/
    public function delete_report_byID($rpt_id){
        $data['rpt_id'] = $rpt_id;
        $num = D("health_report")->where($data)->delete();
        if($num!=0 && $num == 1){
            return true;
        }
        return false;
    }

}